//
//  RandomItems.m
//  Quiz
//
//  Created by YaoJacob on 15/11/1.
//  Copyright © 2015年 Roger. All rights reserved.
//

#import "RandomItems.h"
#import "BNRItem.h"
#import "BNRItemContainer.h"

@implementation RandomItems

- (void)Chapter2Test
{
    NSMutableArray *items;
    BNRItem * item = [[BNRItem alloc]init];
    //        [item _itemName];
    //        item->_itemName = @"a";
    
    item.itemName = @"a";
    NSString * nnn = item.itemName;
    
    NSString * n2 = [item itemName];
    [item setItemName:@"ass"];
    
    //new
    items =[[NSMutableArray alloc]init];
//    for (int i = 0; i <= 10; i++) {
//        [items addObject: [BNRItem randomItem]];
//    }
    
    BNRItem* backPack = [BNRItem randomItem];
    [items addObject:backPack];
    
    BNRItem* calculator = [BNRItem randomItem];
    [items addObject:calculator];
    
    //backPack.containedItem = calculator;
    
    backPack = nil;
    calculator = nil;
    
    for (id itm in items) {
        NSLog(@"%@", itm);
    }
    
    items = nil;
    //items[11];
}

- (void)Chapter2_Advance
{
    //高级问题
    BNRItemContainer * vec = [[BNRItemContainer alloc]init];
    for (int i = 0; i < 3; i++) {
        BNRItem * pp = [BNRItem randomItem];
        int count = [vec addBNRItem:pp];
        NSLog(@"count: %d", count);
    }
    
    NSLog(@"%@", vec);
    
    
    [vec addBNRItem:vec];

    //NSLog(@"%@", vec);//error.
    
    vec = nil;
}

//debug main()
-(void)EnterPoint
{
    @autoreleasepool {
        NSMutableArray *items = [[NSMutableArray alloc]init];
        
        [items addObject:@"One"];
        [items addObject:@"Two"];
        [items addObject:@"Three"];
        
        [items insertObject:@"零" atIndex:0];
        
        for (int i; i < items.count; i++) {
            NSString * item = items[i];
            NSLog(@"%@", item);
        }
        
        //fast
        for (NSString *item in items) {
            NSLog(@"%@", item);
        }
        
        
       // items = nil;
        
        [self Chapter2Test];
//
        //[self Chapter2_Advance];
        
    }
}

@end
